package org.example.ioc;

import org.example.ioc.controller.UserController;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * ClassName: IOCTest
 * Package: org.example.ioc
 * Description:
 *
 * @Author wanghao
 * @Create 2024-07-05 8:20
 * @Version 1.0
 */
public class IOCTest2 {

    private ApplicationContext beanFactory;

    @Before
    public void setup() {
        // 创建ioc容器
//        beanFactory = new AnnotationConfigApplicationContext(MyConfiguration.class);
        beanFactory = new ClassPathXmlApplicationContext("applicationContext.xml");
    }

    @Test
    public void test() {
        beanFactory.getBean(UserController.class).index();
    }

}
